package com.atguigu.gmall.fastdfs;

import org.csource.common.MyException;
import org.csource.fastdfs.*;
import org.springframework.util.ClassUtils;

import java.io.IOException;

public class FastDFSDemo {
    public static void main(String[] args) throws IOException, MyException {

        //获取配置文件全路径
        String path = ClassUtils.getDefaultClassLoader().getResource("fdfs_client.conf").getPath();
        //通过配置文件构建全局配置
        ClientGlobal.init(path);
        TrackerClient trackerClient = new TrackerClient();
        //连接Tracker
        TrackerServer trackerServer = trackerClient.getConnection();
        StorageServer storageServer = null;
        //连接存储节点
        StorageClient1 storageClient1 = new StorageClient1(trackerServer, storageServer);
        //上传图片
        String p = storageClient1.upload_file1("D:\\SGGstu\\尚品汇商城\\资料\\图片\\Apple11\\5f7eafcd01dd2304.jpg", "jpg", null);
        System.out.println(p);

    }
}
